/*
 * Copyright 2011 Mark Davidson.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.dctmcommons;

import com.documentum.fc.client.IDfProcess;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfWorkitem;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.IDfId;

/**
 * Workflow-related helper methods.
 */
public interface IWorkflowHelper {

	/**
	 * Gets a workflow template by name.
	 * @param session The repository session
	 * @param processName The process name
	 * @return The process template
	 * @throws DfException The repository exception
	 */
	public IDfProcess getWorkflowTemplateByName(IDfSession session,
												String processName)
		throws DfException;
	
	/**
	 * Gets a workflow template by qualification.
	 * @param session The repository session
	 * @param qualification The qualification
	 * @return The process template
	 * @throws DfException The repository exception
	 */
	public IDfProcess getWorkflowTemplateByQualification(IDfSession session,
														 String qualification)
		throws DfException;
	
	/**
	 * Sets the next activity.
	 * @param workitem The workitem
	 * @param activityIndex The activity index
	 * @param isForwardActivity Whether to use a forward flow or a reject flow
	 * @throws DfException The repository exception
	 */
	public void moveToNextActivity(IDfWorkitem workitem,
								   int activityNumber,
								   boolean isForwardActivity)
		throws DfException;
	
	/**
	 * Sets the next activity to be the default forward activity.
	 * @param workitem The workitem
	 * @throws DfException The repository exception
	 */
	public void moveToDefaultForwardActivity(IDfWorkitem workitem)
		throws DfException;
	
	/**
	 * Sets the next activity to be the default reject activity.
	 * @param workitem The workitem
	 * @throws DfException The repository exception
	 */
	public void moveToDefaultRejectActivity(IDfWorkitem workitem)
		throws DfException;
	
	/**
	 * Gets the default package document.
	 * @param workitem The workitem
	 * @return The object id
	 * @throws DfException The repository exception
	 */
	public IDfId getDefaultPackageObjectId(IDfWorkitem workitem)
		throws DfException;
	
	/**
	 * Gets the list of package objects for a workitem.
	 * @param workitem The workitem
	 * @return The list of object ids (by package)
	 * @throws DfException The repository exception
	 */
	public String[][] getPackageObjectIds(IDfWorkitem workitem)
		throws DfException;
	
	/**
	 * Adds a note to a workitem's default package.
	 * @param workitem The workitem
	 * @param text the note text
	 * @throws DfException The repository exception
	 */
	public void addNoteToDefaultPackage(IDfWorkitem workitem, String text)
		throws DfException;
}
